package com.example.mobile2021606158zl0401;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

public class MainActivity extends AppCompatActivity {
ImageView ivlight;
Button btnLightON,btnLightOff;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        btnLightON.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ivlight.setImageResource(R.drawable.light_on);
            }
        });
        btnLightOff.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ivlight.setImageResource(R.drawable.light_off);
            }
        });
    }

    private void initView() {
        ivlight=findViewById(R.id.imageView3);
        btnLightON=findViewById(R.id.button3);
        btnLightOff=findViewById(R.id.button4);

    }
}